{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Copyright (c) 2020, NVIDIA CORPORATION.\n",
    "Licensed under the Apache License, Version 2.0 (the \"License\");\n",
    "you may not use this file except in compliance with the License.\n",
    "You may obtain a copy of the License at\n",
    "    http://www.apache.org/licenses/LICENSE-2.0\n",
    "Unless required by applicable law or agreed to in writing, software\n",
    "distributed under the License is distributed on an \"AS IS\" BASIS,\n",
    "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n",
    "See the License for the specific language governing permissions and\n",
    "limitations under the License."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os, time\n",
    "os.environ[\"CUDA_VISIBLE_DEVICES\"]=\"0\"\n",
    "start = time.time()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd, numpy as np, gc\n",
    "from datetime import datetime\n",
    "import joblib\n",
    "\n",
    "import matplotlib.pyplot as plt\n",
    "pd.set_option('display.max_columns', 500)\n",
    "pd.set_option('display.max_rows', 500)\n",
    "#import cudf, cupy\n",
    "#cudf.__version__"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "from numba import jit, njit, prange\n",
    "from sklearn.metrics import precision_recall_curve, auc, log_loss\n",
    "\n",
    "def compute_prauc(gt, pred, nafill=True):\n",
    "    if nafill:\n",
    "        pred[ np.isnan(pred) ] = np.nanmean( pred )\n",
    "    prec, recall, thresh = precision_recall_curve(gt, pred)\n",
    "    prauc = auc(recall, prec)\n",
    "    return prauc\n",
    "\n",
    "@jit\n",
    "def fast_auc(y_true, y_prob):\n",
    "    y_true = np.asarray(y_true)\n",
    "    y_true = y_true[np.argsort(y_prob)]\n",
    "    nfalse = 0\n",
    "    auc = 0\n",
    "    n = len(y_true)\n",
    "    for i in range(n):\n",
    "        y_i = y_true[i]\n",
    "        nfalse += (1 - y_i)\n",
    "        auc += y_i * nfalse\n",
    "    auc /= (nfalse * (n - nfalse))\n",
    "    return auc\n",
    "\n",
    "@njit\n",
    "def numba_log_loss(y,x):\n",
    "    n = x.shape[0]\n",
    "    ll = 0.\n",
    "    for i in prange(n):\n",
    "        if y[i]<=0.:\n",
    "            ll += np.log(1-x[i] + 1e-15 )\n",
    "        else:\n",
    "            ll += np.log(x[i] + 1e-15)\n",
    "    return -ll / n\n",
    "\n",
    "def compute_rce(gt , pred, nafill=True, verbose=0):\n",
    "    if nafill:\n",
    "        pred[ np.isnan(pred) ] = np.nanmean( pred )\n",
    "        \n",
    "    cross_entropy = numba_log_loss( gt, pred  )\n",
    "    \n",
    "    yt = np.mean(gt>0)     \n",
    "    strawman_cross_entropy = -(yt*np.log(yt) + (1 - yt)*np.log(1 - yt))\n",
    "    \n",
    "    if verbose:\n",
    "        print( \"logloss: {0:.5f} / {1:.5f} = {2:.5f}\".format(cross_entropy, strawman_cross_entropy, cross_entropy/strawman_cross_entropy))\n",
    "        print( 'mean:    {0:.5f} / {1:.5f}'.format( np.nanmean( pred ) , yt  ) )\n",
    "    \n",
    "    return (1.0 - cross_entropy/strawman_cross_entropy)*100.0\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "def save_memory( df ):\n",
    "    features = df.columns\n",
    "    for i in range( df.shape[1] ):\n",
    "        if df.dtypes[i] == 'uint8':\n",
    "            df[features[i]] = df[features[i]].astype( np.int8 )\n",
    "            gc.collect()\n",
    "        elif df.dtypes[i] == 'bool':\n",
    "            df[features[i]] = df[features[i]].astype( np.int8 )\n",
    "            gc.collect()\n",
    "        elif df.dtypes[i] == 'uint32':\n",
    "            df[features[i]] = df[features[i]].astype( np.int32 )\n",
    "            gc.collect()\n",
    "        elif df.dtypes[i] == 'int64':\n",
    "            df[features[i]] = df[features[i]].astype( np.int32 )\n",
    "            gc.collect()\n",
    "        elif df.dtypes[i] == 'float64':\n",
    "            df[features[i]] = df[features[i]].astype( np.float32 )\n",
    "            gc.collect()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Load Train"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "((121386431, 25), (12434735, 25), (12434838, 25))"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train = pd.read_parquet( 'train-1.parquet' )\n",
    "test0 = pd.read_parquet( 'test-0.parquet' )\n",
    "test1 = pd.read_parquet( 'test-1.parquet' )\n",
    "gc.collect()\n",
    "\n",
    "train['tr'] = 0\n",
    "test0['tr'] = 1\n",
    "test1['tr'] = 1\n",
    "\n",
    "train.shape, test0.shape, test1.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(146256004, 25)"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train = pd.concat( (train,test0,test1), sort=False )\n",
    "gc.collect()\n",
    "del test0,test1\n",
    "gc.collect()\n",
    "\n",
    "train.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 1min 25s, sys: 13.3 s, total: 1min 39s\n",
      "Wall time: 1min 39s\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%%time\n",
    "train = train.sort_values('timestamp').reset_index(drop=True) #TIME ORDER\n",
    "gc.collect()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train.loc[ train.reply>0, 'reply' ] = 1\n",
    "train.loc[ train.retweet>0, 'retweet' ] = 1\n",
    "train.loc[ train.retweet_comment>0, 'retweet_comment' ] = 1\n",
    "train.loc[ train.like>0, 'like' ] = 1\n",
    "\n",
    "train['engage'] = 0\n",
    "train.loc[ (train.reply>0)|(train.retweet>0)|(train.retweet_comment>0)|(train.like>0)  , 'engage'] = 1\n",
    "gc.collect()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>hashtags</th>\n",
       "      <th>tweet_id</th>\n",
       "      <th>media</th>\n",
       "      <th>links</th>\n",
       "      <th>domains</th>\n",
       "      <th>tweet_type</th>\n",
       "      <th>language</th>\n",
       "      <th>timestamp</th>\n",
       "      <th>a_user_id</th>\n",
       "      <th>a_follower_count</th>\n",
       "      <th>a_following_count</th>\n",
       "      <th>a_is_verified</th>\n",
       "      <th>a_account_creation</th>\n",
       "      <th>b_user_id</th>\n",
       "      <th>b_follower_count</th>\n",
       "      <th>b_following_count</th>\n",
       "      <th>b_is_verified</th>\n",
       "      <th>b_account_creation</th>\n",
       "      <th>b_follows_a</th>\n",
       "      <th>reply</th>\n",
       "      <th>retweet</th>\n",
       "      <th>retweet_comment</th>\n",
       "      <th>like</th>\n",
       "      <th>id</th>\n",
       "      <th>tr</th>\n",
       "      <th>engage</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>84383</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>59</td>\n",
       "      <td>1580947200</td>\n",
       "      <td>7581</td>\n",
       "      <td>1438254</td>\n",
       "      <td>268</td>\n",
       "      <td>True</td>\n",
       "      <td>1301520627</td>\n",
       "      <td>22274968</td>\n",
       "      <td>41</td>\n",
       "      <td>379</td>\n",
       "      <td>False</td>\n",
       "      <td>1259102347</td>\n",
       "      <td>False</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>96855085</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0</td>\n",
       "      <td>3992746</td>\n",
       "      <td>5</td>\n",
       "      <td>473701</td>\n",
       "      <td>9</td>\n",
       "      <td>2</td>\n",
       "      <td>59</td>\n",
       "      <td>1580947200</td>\n",
       "      <td>4749</td>\n",
       "      <td>1045996</td>\n",
       "      <td>518</td>\n",
       "      <td>True</td>\n",
       "      <td>1235504861</td>\n",
       "      <td>23956872</td>\n",
       "      <td>0</td>\n",
       "      <td>64</td>\n",
       "      <td>False</td>\n",
       "      <td>1557970591</td>\n",
       "      <td>False</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>57701281</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0</td>\n",
       "      <td>789758</td>\n",
       "      <td>9</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>54</td>\n",
       "      <td>1580947200</td>\n",
       "      <td>12117</td>\n",
       "      <td>71231</td>\n",
       "      <td>3819</td>\n",
       "      <td>False</td>\n",
       "      <td>1352943191</td>\n",
       "      <td>18642489</td>\n",
       "      <td>13</td>\n",
       "      <td>65</td>\n",
       "      <td>False</td>\n",
       "      <td>1524243737</td>\n",
       "      <td>False</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>89623685</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0</td>\n",
       "      <td>6912703</td>\n",
       "      <td>5</td>\n",
       "      <td>141941</td>\n",
       "      <td>9</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>1580947200</td>\n",
       "      <td>297779</td>\n",
       "      <td>209838</td>\n",
       "      <td>204</td>\n",
       "      <td>True</td>\n",
       "      <td>1333746722</td>\n",
       "      <td>19850999</td>\n",
       "      <td>75</td>\n",
       "      <td>968</td>\n",
       "      <td>False</td>\n",
       "      <td>1306118149</td>\n",
       "      <td>False</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>51022269</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0</td>\n",
       "      <td>1508672</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>54</td>\n",
       "      <td>1580947200</td>\n",
       "      <td>53927</td>\n",
       "      <td>161464</td>\n",
       "      <td>5531</td>\n",
       "      <td>True</td>\n",
       "      <td>1260797124</td>\n",
       "      <td>15177916</td>\n",
       "      <td>94</td>\n",
       "      <td>220</td>\n",
       "      <td>False</td>\n",
       "      <td>1321907890</td>\n",
       "      <td>False</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2699787</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   hashtags  tweet_id  media   links  domains  tweet_type  language  \\\n",
       "0         0     84383      5       0        0           2        59   \n",
       "1         0   3992746      5  473701        9           2        59   \n",
       "2         0    789758      9       0        0           2        54   \n",
       "3         0   6912703      5  141941        9           2         3   \n",
       "4         0   1508672      5       0        0           2        54   \n",
       "\n",
       "    timestamp  a_user_id  a_follower_count  a_following_count  a_is_verified  \\\n",
       "0  1580947200       7581           1438254                268           True   \n",
       "1  1580947200       4749           1045996                518           True   \n",
       "2  1580947200      12117             71231               3819          False   \n",
       "3  1580947200     297779            209838                204           True   \n",
       "4  1580947200      53927            161464               5531           True   \n",
       "\n",
       "   a_account_creation  b_user_id  b_follower_count  b_following_count  \\\n",
       "0          1301520627   22274968                41                379   \n",
       "1          1235504861   23956872                 0                 64   \n",
       "2          1352943191   18642489                13                 65   \n",
       "3          1333746722   19850999                75                968   \n",
       "4          1260797124   15177916                94                220   \n",
       "\n",
       "   b_is_verified  b_account_creation  b_follows_a  reply  retweet  \\\n",
       "0          False          1259102347        False      0        0   \n",
       "1          False          1557970591        False      0        0   \n",
       "2          False          1524243737        False      0        0   \n",
       "3          False          1306118149        False      0        0   \n",
       "4          False          1321907890        False      0        0   \n",
       "\n",
       "   retweet_comment  like        id  tr  engage  \n",
       "0                0     0  96855085   0       0  \n",
       "1                0     0  57701281   0       0  \n",
       "2                0     0  89623685   0       0  \n",
       "3                0     0  51022269   0       0  \n",
       "4                0     1   2699787   0       1  "
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "save_memory(train)\n",
    "gc.collect()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "hashtags              int32\n",
       "tweet_id              int32\n",
       "media                  int8\n",
       "links                 int32\n",
       "domains               int32\n",
       "tweet_type             int8\n",
       "language               int8\n",
       "timestamp             int32\n",
       "a_user_id             int32\n",
       "a_follower_count      int32\n",
       "a_following_count     int32\n",
       "a_is_verified          int8\n",
       "a_account_creation    int32\n",
       "b_user_id             int32\n",
       "b_follower_count      int32\n",
       "b_following_count     int32\n",
       "b_is_verified          int8\n",
       "b_account_creation    int32\n",
       "b_follows_a            int8\n",
       "reply                 int32\n",
       "retweet               int32\n",
       "retweet_comment       int32\n",
       "like                  int32\n",
       "id                    int32\n",
       "tr                    int32\n",
       "engage                int32\n",
       "dtype: object"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train.dtypes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>tr</th>\n",
       "      <th>a_user_id</th>\n",
       "      <th>a_follower_count</th>\n",
       "      <th>a_following_count</th>\n",
       "      <th>timestamp</th>\n",
       "      <th>id</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>7581</td>\n",
       "      <td>1438254</td>\n",
       "      <td>268</td>\n",
       "      <td>1580947200</td>\n",
       "      <td>96855085</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0</td>\n",
       "      <td>4749</td>\n",
       "      <td>1045996</td>\n",
       "      <td>518</td>\n",
       "      <td>1580947200</td>\n",
       "      <td>57701281</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0</td>\n",
       "      <td>12117</td>\n",
       "      <td>71231</td>\n",
       "      <td>3819</td>\n",
       "      <td>1580947200</td>\n",
       "      <td>89623685</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0</td>\n",
       "      <td>297779</td>\n",
       "      <td>209838</td>\n",
       "      <td>204</td>\n",
       "      <td>1580947200</td>\n",
       "      <td>51022269</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0</td>\n",
       "      <td>53927</td>\n",
       "      <td>161464</td>\n",
       "      <td>5531</td>\n",
       "      <td>1580947200</td>\n",
       "      <td>2699787</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   tr  a_user_id  a_follower_count  a_following_count   timestamp        id\n",
       "0   0       7581           1438254                268  1580947200  96855085\n",
       "1   0       4749           1045996                518  1580947200  57701281\n",
       "2   0      12117             71231               3819  1580947200  89623685\n",
       "3   0     297779            209838                204  1580947200  51022269\n",
       "4   0      53927            161464               5531  1580947200   2699787"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dt0 = train[['tr','a_user_id','a_follower_count','a_following_count','timestamp','id']].copy()\n",
    "dt1 = train[['tr','b_user_id','b_follower_count','b_following_count','timestamp','id']].copy()\n",
    "dt1.columns = ['tr','a_user_id','a_follower_count','a_following_count','timestamp','id']\n",
    "dt1['id'] = -1\n",
    "dt = pd.concat( (dt0,dt1), sort=False )\n",
    "del dt0,dt1; _=gc.collect()\n",
    "dt.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 6min 2s, sys: 42.8 s, total: 6min 45s\n",
      "Wall time: 6min 45s\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       " 1    196262061\n",
       " 0     63402710\n",
       "-1     32847237\n",
       "Name: a_fc_dif_flag, dtype: int64"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%%time\n",
    "dt['a_fc_max'] = dt.groupby(['tr','a_user_id','a_follower_count'])['timestamp'].transform('max'); _=gc.collect()\n",
    "dt['a_fc_min'] = dt.groupby(['tr','a_user_id','a_follower_count'])['timestamp'].transform('min'); _=gc.collect()\n",
    "\n",
    "dt['a_fc_dif'] = dt['a_fc_max'] - dt['a_fc_min']; _=gc.collect()\n",
    "\n",
    "dt['a_fc_dif_max'] = dt.groupby(['tr','a_user_id'])['a_fc_dif'].transform('max'); _=gc.collect()\n",
    "\n",
    "dt['a_fc_dif_flag'] = 1* ((dt['a_fc_dif'] == dt['a_fc_dif_max']) )  ; _=gc.collect()\n",
    "dt.loc[ dt.a_fc_dif==0 ,'a_fc_dif_flag'] = -1\n",
    "\n",
    "del dt['a_fc_max'],dt['a_fc_min'],dt['a_fc_dif'],dt['a_fc_dif_max'] ; _=gc.collect()\n",
    "dt['a_fc_dif_flag'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       " 1    84461566\n",
       " 0    47340973\n",
       "-1    14453465\n",
       "Name: a_user_fer_count_delta_time, dtype: int64"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train['a_user_fer_count_delta_time'] = train.merge( dt, on='id', how='left' )['a_fc_dif_flag'] ; _=gc.collect()\n",
    "\n",
    "del dt['a_fc_dif_flag'] ; _=gc.collect()\n",
    "\n",
    "train['a_user_fer_count_delta_time'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead tr th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe thead tr:last-of-type th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>reply</th>\n",
       "      <th>retweet</th>\n",
       "      <th>retweet_comment</th>\n",
       "      <th>like</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>mean</th>\n",
       "      <th>mean</th>\n",
       "      <th>mean</th>\n",
       "      <th>mean</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>tr</th>\n",
       "      <th>a_user_fer_count_delta_time</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">0</th>\n",
       "      <th>-1</th>\n",
       "      <td>0.020248</td>\n",
       "      <td>0.043432</td>\n",
       "      <td>0.004040</td>\n",
       "      <td>0.203374</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.000739</td>\n",
       "      <td>0.002376</td>\n",
       "      <td>0.000192</td>\n",
       "      <td>0.008607</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.040521</td>\n",
       "      <td>0.179154</td>\n",
       "      <td>0.011767</td>\n",
       "      <td>0.708384</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">1</th>\n",
       "      <th>-1</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                   reply   retweet retweet_comment      like\n",
       "                                    mean      mean            mean      mean\n",
       "tr a_user_fer_count_delta_time                                              \n",
       "0  -1                           0.020248  0.043432        0.004040  0.203374\n",
       "    0                           0.000739  0.002376        0.000192  0.008607\n",
       "    1                           0.040521  0.179154        0.011767  0.708384\n",
       "1  -1                           0.000000  0.000000        0.000000  0.000000\n",
       "    0                           0.000000  0.000000        0.000000  0.000000\n",
       "    1                           0.000000  0.000000        0.000000  0.000000"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train.groupby(['tr','a_user_fer_count_delta_time'])[['reply','retweet','retweet_comment','like']].agg(['mean'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 5min 54s, sys: 42.8 s, total: 6min 36s\n",
      "Wall time: 6min 36s\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       " 1    211322540\n",
       " 0     48322632\n",
       "-1     32866836\n",
       "Name: a_fc_dif_flag, dtype: int64"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%%time\n",
    "dt['a_fc_max'] = dt.groupby(['tr','a_user_id','a_following_count'])['timestamp'].transform('max'); _=gc.collect()\n",
    "dt['a_fc_min'] = dt.groupby(['tr','a_user_id','a_following_count'])['timestamp'].transform('min'); _=gc.collect()\n",
    "\n",
    "dt['a_fc_dif'] = dt['a_fc_max'] - dt['a_fc_min']; _=gc.collect()\n",
    "\n",
    "dt['a_fc_dif_max'] = dt.groupby(['tr','a_user_id'])['a_fc_dif'].transform('max'); _=gc.collect()\n",
    "\n",
    "dt['a_fc_dif_flag'] = 1* ((dt['a_fc_dif'] == dt['a_fc_dif_max']) )  ; _=gc.collect()\n",
    "dt.loc[ dt.a_fc_dif==0 ,'a_fc_dif_flag'] = -1\n",
    "\n",
    "del dt['a_fc_max'],dt['a_fc_min'],dt['a_fc_dif'],dt['a_fc_dif_max'] ; _=gc.collect()\n",
    "dt['a_fc_dif_flag'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       " 1    103337405\n",
       " 0     31090824\n",
       "-1     11827775\n",
       "Name: a_user_fing_count_delta_time, dtype: int64"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train['a_user_fing_count_delta_time'] = train.merge( dt, on='id', how='left' )['a_fc_dif_flag'] ; _=gc.collect()\n",
    "\n",
    "del dt['a_fc_dif_flag'] ; _=gc.collect()\n",
    "\n",
    "train['a_user_fing_count_delta_time'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead tr th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe thead tr:last-of-type th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>reply</th>\n",
       "      <th>retweet</th>\n",
       "      <th>retweet_comment</th>\n",
       "      <th>like</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>mean</th>\n",
       "      <th>mean</th>\n",
       "      <th>mean</th>\n",
       "      <th>mean</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>tr</th>\n",
       "      <th>a_user_fing_count_delta_time</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">0</th>\n",
       "      <th>-1</th>\n",
       "      <td>0.024621</td>\n",
       "      <td>0.051793</td>\n",
       "      <td>0.004836</td>\n",
       "      <td>0.244370</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.001318</td>\n",
       "      <td>0.004249</td>\n",
       "      <td>0.000348</td>\n",
       "      <td>0.015821</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.033272</td>\n",
       "      <td>0.147138</td>\n",
       "      <td>0.009664</td>\n",
       "      <td>0.581720</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">1</th>\n",
       "      <th>-1</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                    reply   retweet retweet_comment      like\n",
       "                                     mean      mean            mean      mean\n",
       "tr a_user_fing_count_delta_time                                              \n",
       "0  -1                            0.024621  0.051793        0.004836  0.244370\n",
       "    0                            0.001318  0.004249        0.000348  0.015821\n",
       "    1                            0.033272  0.147138        0.009664  0.581720\n",
       "1  -1                            0.000000  0.000000        0.000000  0.000000\n",
       "    0                            0.000000  0.000000        0.000000  0.000000\n",
       "    1                            0.000000  0.000000        0.000000  0.000000"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train.groupby(['tr','a_user_fing_count_delta_time'])[['reply','retweet','retweet_comment','like']].agg(['mean'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 6min 19s, sys: 46.5 s, total: 7min 6s\n",
      "Wall time: 7min 6s\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       " 1    181396527\n",
       " 0     66142423\n",
       "-1     44973058\n",
       "Name: a_fc_dif_flag, dtype: int64"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%%time\n",
    "dt['a_fc_max'] = dt.groupby(['tr','a_user_id','a_follower_count','a_following_count'])['timestamp'].transform('max'); _=gc.collect()\n",
    "dt['a_fc_min'] = dt.groupby(['tr','a_user_id','a_follower_count','a_following_count'])['timestamp'].transform('min'); _=gc.collect()\n",
    "\n",
    "dt['a_fc_dif'] = dt['a_fc_max'] - dt['a_fc_min']; _=gc.collect()\n",
    "\n",
    "dt['a_fc_dif_max'] = dt.groupby(['tr','a_user_id'])['a_fc_dif'].transform('max'); _=gc.collect()\n",
    "\n",
    "dt['a_fc_dif_flag'] = 1* ((dt['a_fc_dif'] == dt['a_fc_dif_max']) )  ; _=gc.collect()\n",
    "dt.loc[ dt.a_fc_dif==0 ,'a_fc_dif_flag'] = -1\n",
    "\n",
    "del dt['a_fc_max'],dt['a_fc_min'],dt['a_fc_dif'],dt['a_fc_dif_max'] ; _=gc.collect()\n",
    "dt['a_fc_dif_flag'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       " 1    82346467\n",
       " 0    47606577\n",
       "-1    16302960\n",
       "Name: a_user_fering_count_delta_time, dtype: int64"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train['a_user_fering_count_delta_time'] = train.merge( dt, on='id', how='left' )['a_fc_dif_flag'] ; _=gc.collect()\n",
    "\n",
    "del dt['a_fc_dif_flag'] ; _=gc.collect()\n",
    "\n",
    "train['a_user_fering_count_delta_time'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead tr th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe thead tr:last-of-type th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>reply</th>\n",
       "      <th>retweet</th>\n",
       "      <th>retweet_comment</th>\n",
       "      <th>like</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>mean</th>\n",
       "      <th>mean</th>\n",
       "      <th>mean</th>\n",
       "      <th>mean</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>tr</th>\n",
       "      <th>a_user_fering_count_delta_time</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">0</th>\n",
       "      <th>-1</th>\n",
       "      <td>0.018202</td>\n",
       "      <td>0.039295</td>\n",
       "      <td>0.003652</td>\n",
       "      <td>0.182442</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.000494</td>\n",
       "      <td>0.001632</td>\n",
       "      <td>0.000123</td>\n",
       "      <td>0.005825</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.041600</td>\n",
       "      <td>0.183938</td>\n",
       "      <td>0.012086</td>\n",
       "      <td>0.727258</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">1</th>\n",
       "      <th>-1</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                      reply   retweet retweet_comment  \\\n",
       "                                       mean      mean            mean   \n",
       "tr a_user_fering_count_delta_time                                       \n",
       "0  -1                              0.018202  0.039295        0.003652   \n",
       "    0                              0.000494  0.001632        0.000123   \n",
       "    1                              0.041600  0.183938        0.012086   \n",
       "1  -1                              0.000000  0.000000        0.000000   \n",
       "    0                              0.000000  0.000000        0.000000   \n",
       "    1                              0.000000  0.000000        0.000000   \n",
       "\n",
       "                                       like  \n",
       "                                       mean  \n",
       "tr a_user_fering_count_delta_time            \n",
       "0  -1                              0.182442  \n",
       "    0                              0.005825  \n",
       "    1                              0.727258  \n",
       "1  -1                              0.000000  \n",
       "    0                              0.000000  \n",
       "    1                              0.000000  "
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train.groupby(['tr','a_user_fering_count_delta_time'])[['reply','retweet','retweet_comment','like']].agg(['mean'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 3min 36s, sys: 24.5 s, total: 4min\n",
      "Wall time: 4min\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       " 1    219055122\n",
       " 0     41868436\n",
       "-1     31588450\n",
       "Name: a_fc_count_flag, dtype: int64"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%%time\n",
    "dt['a_fc_count'] = dt.groupby(['tr','a_user_id','a_following_count'])['id'].transform('count'); _=gc.collect()\n",
    "dt['a_fc_max']   = dt.groupby(['tr','a_user_id'])['a_fc_count'].transform('max'); _=gc.collect()\n",
    "dt['a_fc_count_flag'] = 1* ((dt['a_fc_count'] == dt['a_fc_max']))  ; _=gc.collect()\n",
    "dt.loc[ dt.a_fc_count<=1,'a_fc_count_flag'] = -1\n",
    "\n",
    "del dt['a_fc_count'], dt['a_fc_max']\n",
    "dt['a_fc_count_flag'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       " 1    106413330\n",
       " 0     29292845\n",
       "-1     10549829\n",
       "Name: a_user_fing_count_mode, dtype: int64"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train['a_user_fing_count_mode'] = train.merge( dt, on='id', how='left' )['a_fc_count_flag'] ; _=gc.collect()\n",
    "del dt['a_fc_count_flag'] ; _=gc.collect()\n",
    "train['a_user_fing_count_mode'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead tr th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe thead tr:last-of-type th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>reply</th>\n",
       "      <th>retweet</th>\n",
       "      <th>retweet_comment</th>\n",
       "      <th>like</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>mean</th>\n",
       "      <th>mean</th>\n",
       "      <th>mean</th>\n",
       "      <th>mean</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>tr</th>\n",
       "      <th>a_user_fing_count_mode</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">0</th>\n",
       "      <th>-1</th>\n",
       "      <td>0.025053</td>\n",
       "      <td>0.049914</td>\n",
       "      <td>0.004816</td>\n",
       "      <td>0.222856</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.002767</td>\n",
       "      <td>0.009126</td>\n",
       "      <td>0.000868</td>\n",
       "      <td>0.037778</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.032191</td>\n",
       "      <td>0.142372</td>\n",
       "      <td>0.009304</td>\n",
       "      <td>0.563611</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">1</th>\n",
       "      <th>-1</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                              reply   retweet retweet_comment      like\n",
       "                               mean      mean            mean      mean\n",
       "tr a_user_fing_count_mode                                              \n",
       "0  -1                      0.025053  0.049914        0.004816  0.222856\n",
       "    0                      0.002767  0.009126        0.000868  0.037778\n",
       "    1                      0.032191  0.142372        0.009304  0.563611\n",
       "1  -1                      0.000000  0.000000        0.000000  0.000000\n",
       "    0                      0.000000  0.000000        0.000000  0.000000\n",
       "    1                      0.000000  0.000000        0.000000  0.000000"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train.groupby(['tr','a_user_fing_count_mode'])[['reply','retweet','retweet_comment','like']].agg(['mean'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 3min 51s, sys: 25.7 s, total: 4min 17s\n",
      "Wall time: 4min 17s\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       " 1    203146666\n",
       " 0     59085591\n",
       "-1     30279751\n",
       "Name: a_fc_count_flag, dtype: int64"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%%time\n",
    "dt['a_fc_count'] = dt.groupby(['tr','a_user_id','a_follower_count'])['id'].transform('count'); _=gc.collect()\n",
    "dt['a_fc_max']   = dt.groupby(['tr','a_user_id'])['a_fc_count'].transform('max'); _=gc.collect()\n",
    "dt['a_fc_count_flag'] = 1* ((dt['a_fc_count'] == dt['a_fc_max']))  ; _=gc.collect()\n",
    "dt.loc[ dt.a_fc_count<=1,'a_fc_count_flag'] = -1\n",
    "\n",
    "del dt['a_fc_count'], dt['a_fc_max']\n",
    "dt['a_fc_count_flag'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       " 1    87289061\n",
       " 0    47080579\n",
       "-1    11886364\n",
       "Name: a_user_fer_count_mode, dtype: int64"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train['a_user_fer_count_mode'] = train.merge( dt, on='id', how='left' )['a_fc_count_flag'] ; _=gc.collect()\n",
    "del dt['a_fc_count_flag'] ; _=gc.collect()\n",
    "train['a_user_fer_count_mode'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead tr th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe thead tr:last-of-type th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>reply</th>\n",
       "      <th>retweet</th>\n",
       "      <th>retweet_comment</th>\n",
       "      <th>like</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>mean</th>\n",
       "      <th>mean</th>\n",
       "      <th>mean</th>\n",
       "      <th>mean</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>tr</th>\n",
       "      <th>a_user_fer_count_mode</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">0</th>\n",
       "      <th>-1</th>\n",
       "      <td>0.022789</td>\n",
       "      <td>0.046336</td>\n",
       "      <td>0.004451</td>\n",
       "      <td>0.205478</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.001172</td>\n",
       "      <td>0.004023</td>\n",
       "      <td>0.000345</td>\n",
       "      <td>0.016506</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.039363</td>\n",
       "      <td>0.173680</td>\n",
       "      <td>0.011396</td>\n",
       "      <td>0.687849</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">1</th>\n",
       "      <th>-1</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                             reply   retweet retweet_comment      like\n",
       "                              mean      mean            mean      mean\n",
       "tr a_user_fer_count_mode                                              \n",
       "0  -1                     0.022789  0.046336        0.004451  0.205478\n",
       "    0                     0.001172  0.004023        0.000345  0.016506\n",
       "    1                     0.039363  0.173680        0.011396  0.687849\n",
       "1  -1                     0.000000  0.000000        0.000000  0.000000\n",
       "    0                     0.000000  0.000000        0.000000  0.000000\n",
       "    1                     0.000000  0.000000        0.000000  0.000000"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train.groupby(['tr','a_user_fer_count_mode'])[['reply','retweet','retweet_comment','like']].agg(['mean'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 4min 15s, sys: 28.3 s, total: 4min 43s\n",
      "Wall time: 4min 43s\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       " 1    189397117\n",
       " 0     60798233\n",
       "-1     42316658\n",
       "Name: a_fc_count_flag, dtype: int64"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%%time\n",
    "dt['a_fc_count'] = dt.groupby(['tr','a_user_id','a_follower_count','a_following_count'])['id'].transform('count'); _=gc.collect()\n",
    "dt['a_fc_max']   = dt.groupby(['tr','a_user_id'])['a_fc_count'].transform('max'); _=gc.collect()\n",
    "dt['a_fc_count_flag'] = 1* ((dt['a_fc_count'] == dt['a_fc_max']))  ; _=gc.collect()\n",
    "dt.loc[ dt.a_fc_count<=1,'a_fc_count_flag'] = -1\n",
    "\n",
    "del dt['a_fc_count'], dt['a_fc_max']\n",
    "dt['a_fc_count_flag'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       " 1    85155540\n",
       " 0    47453340\n",
       "-1    13647124\n",
       "Name: a_user_fering_count_mode, dtype: int64"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train['a_user_fering_count_mode'] = train.merge( dt, on='id', how='left' )['a_fc_count_flag'] ; _=gc.collect()\n",
    "del dt['a_fc_count_flag'] ; _=gc.collect()\n",
    "train['a_user_fering_count_mode'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead tr th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe thead tr:last-of-type th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>reply</th>\n",
       "      <th>retweet</th>\n",
       "      <th>retweet_comment</th>\n",
       "      <th>like</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>mean</th>\n",
       "      <th>mean</th>\n",
       "      <th>mean</th>\n",
       "      <th>mean</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>tr</th>\n",
       "      <th>a_user_fering_count_mode</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">0</th>\n",
       "      <th>-1</th>\n",
       "      <td>0.019990</td>\n",
       "      <td>0.041058</td>\n",
       "      <td>0.003934</td>\n",
       "      <td>0.180545</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.001066</td>\n",
       "      <td>0.003681</td>\n",
       "      <td>0.000312</td>\n",
       "      <td>0.015235</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.040303</td>\n",
       "      <td>0.177959</td>\n",
       "      <td>0.011675</td>\n",
       "      <td>0.704806</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">1</th>\n",
       "      <th>-1</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                reply   retweet retweet_comment      like\n",
       "                                 mean      mean            mean      mean\n",
       "tr a_user_fering_count_mode                                              \n",
       "0  -1                        0.019990  0.041058        0.003934  0.180545\n",
       "    0                        0.001066  0.003681        0.000312  0.015235\n",
       "    1                        0.040303  0.177959        0.011675  0.704806\n",
       "1  -1                        0.000000  0.000000        0.000000  0.000000\n",
       "    0                        0.000000  0.000000        0.000000  0.000000\n",
       "    1                        0.000000  0.000000        0.000000  0.000000"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train.groupby(['tr','a_user_fering_count_mode'])[['reply','retweet','retweet_comment','like']].agg(['mean'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [],
   "source": [
    "del dt; _=gc.collect()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2      78746518\n",
       "1      23801964\n",
       "0      16748586\n",
       "10      9222848\n",
       "5       2171185\n",
       "15      1834331\n",
       "4       1254366\n",
       "3       1213266\n",
       "6       1148744\n",
       "13       883950\n",
       "12       858675\n",
       "29       851647\n",
       "36       717321\n",
       "7        664803\n",
       "21       612722\n",
       "35       496340\n",
       "9        485131\n",
       "8        414983\n",
       "22       361278\n",
       "30       359131\n",
       "18       295766\n",
       "25       267802\n",
       "27       267234\n",
       "49       240921\n",
       "32       188563\n",
       "37       144436\n",
       "23       118961\n",
       "41       114718\n",
       "28       107623\n",
       "54        97331\n",
       "16        94860\n",
       "46        86903\n",
       "44        83745\n",
       "17        74064\n",
       "24        72108\n",
       "50        66234\n",
       "34        63939\n",
       "51        53529\n",
       "19        48210\n",
       "53        47556\n",
       "38        46088\n",
       "72        45505\n",
       "11        44324\n",
       "42        43461\n",
       "43        42764\n",
       "26        42147\n",
       "56        38664\n",
       "48        36448\n",
       "89        29813\n",
       "87        28157\n",
       "31        27810\n",
       "60        26811\n",
       "61        22234\n",
       "63        21258\n",
       "57        19359\n",
       "74        18958\n",
       "40        18169\n",
       "69        17053\n",
       "47        16677\n",
       "59        16108\n",
       "64        16038\n",
       "65        13955\n",
       "45        13018\n",
       "68        12871\n",
       "58        12234\n",
       "66        11679\n",
       "52        11416\n",
       "39        11213\n",
       "33        10614\n",
       "71         9437\n",
       "101        9383\n",
       "81         8757\n",
       "96         7296\n",
       "77         7207\n",
       "85         6554\n",
       "20         6540\n",
       "88         6110\n",
       "100        5739\n",
       "67         5396\n",
       "70         5391\n",
       "91         4642\n",
       "83         4259\n",
       "14         4131\n",
       "90         4068\n",
       "84         3946\n",
       "86         3807\n",
       "76         3442\n",
       "99         3387\n",
       "125        2917\n",
       "93         2763\n",
       "78         2680\n",
       "73         2665\n",
       "107        2347\n",
       "94         2260\n",
       "97         2106\n",
       "98         1947\n",
       "55         1944\n",
       "123        1849\n",
       "95         1834\n",
       "62         1790\n",
       "104        1647\n",
       "111        1241\n",
       "121        1237\n",
       "119        1130\n",
       "110        1074\n",
       "126         940\n",
       "92          798\n",
       "130         772\n",
       "82          755\n",
       "122         726\n",
       "118         725\n",
       "79          720\n",
       "131         699\n",
       "128         620\n",
       "120         577\n",
       "116         573\n",
       "103         557\n",
       "113         550\n",
       "75          514\n",
       "108         500\n",
       "102         498\n",
       "136         428\n",
       "112         408\n",
       "109         398\n",
       "105         395\n",
       "143         387\n",
       "106         371\n",
       "117         344\n",
       "134         335\n",
       "115         317\n",
       "80          315\n",
       "144         300\n",
       "142         284\n",
       "124         164\n",
       "140         132\n",
       "127         105\n",
       "149          98\n",
       "114          70\n",
       "133          63\n",
       "138          60\n",
       "137          52\n",
       "156          44\n",
       "141          41\n",
       "146          39\n",
       "148          31\n",
       "165          27\n",
       "132          24\n",
       "129          22\n",
       "153          18\n",
       "160          16\n",
       "152          15\n",
       "135          12\n",
       "145          12\n",
       "139          12\n",
       "150           9\n",
       "155           8\n",
       "158           8\n",
       "162           6\n",
       "163           6\n",
       "164           6\n",
       "151           5\n",
       "154           5\n",
       "159           5\n",
       "167           4\n",
       "147           4\n",
       "157           3\n",
       "169           2\n",
       "161           2\n",
       "166           2\n",
       "170           2\n",
       "171           2\n",
       "168           1\n",
       "Name: a_count_combined, dtype: int64"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train['a_count_combined'] = pd.factorize(\n",
    "    (1+train['a_user_fer_count_delta_time'])*3**0 +\n",
    "    (1+train['a_user_fing_count_delta_time'])*3**1 +\n",
    "    (1+train['a_user_fering_count_delta_time'])*3**2 +\n",
    "    (1+train['a_user_fing_count_mode'])*3**3 +\n",
    "    (1+train['a_user_fer_count_mode'])*3**4 +\n",
    "    (1+train['a_user_fering_count_mode'])*3**5 \n",
    ")[0]\n",
    "train['a_count_combined'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead tr th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe thead tr:last-of-type th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th>reply</th>\n",
       "      <th>retweet</th>\n",
       "      <th>retweet_comment</th>\n",
       "      <th>like</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th>mean</th>\n",
       "      <th>mean</th>\n",
       "      <th>mean</th>\n",
       "      <th>mean</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>a_count_combined</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.000134</td>\n",
       "      <td>0.000483</td>\n",
       "      <td>0.000036</td>\n",
       "      <td>0.001738</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.000122</td>\n",
       "      <td>0.000366</td>\n",
       "      <td>0.000028</td>\n",
       "      <td>0.001323</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.041770</td>\n",
       "      <td>0.186519</td>\n",
       "      <td>0.012111</td>\n",
       "      <td>0.736756</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.005150</td>\n",
       "      <td>0.016041</td>\n",
       "      <td>0.001395</td>\n",
       "      <td>0.058424</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.003689</td>\n",
       "      <td>0.014470</td>\n",
       "      <td>0.000967</td>\n",
       "      <td>0.051986</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>0.000054</td>\n",
       "      <td>0.000196</td>\n",
       "      <td>0.000017</td>\n",
       "      <td>0.000704</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>0.038237</td>\n",
       "      <td>0.128285</td>\n",
       "      <td>0.012932</td>\n",
       "      <td>0.545995</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>0.029493</td>\n",
       "      <td>0.110948</td>\n",
       "      <td>0.009350</td>\n",
       "      <td>0.476620</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>0.000804</td>\n",
       "      <td>0.002577</td>\n",
       "      <td>0.000232</td>\n",
       "      <td>0.015041</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>0.034245</td>\n",
       "      <td>0.113368</td>\n",
       "      <td>0.010275</td>\n",
       "      <td>0.491770</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>0.028490</td>\n",
       "      <td>0.056141</td>\n",
       "      <td>0.005435</td>\n",
       "      <td>0.252894</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>0.031611</td>\n",
       "      <td>0.112540</td>\n",
       "      <td>0.010479</td>\n",
       "      <td>0.413701</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>0.000359</td>\n",
       "      <td>0.001182</td>\n",
       "      <td>0.000083</td>\n",
       "      <td>0.005582</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>0.001775</td>\n",
       "      <td>0.005154</td>\n",
       "      <td>0.000360</td>\n",
       "      <td>0.018248</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>0.000806</td>\n",
       "      <td>0.003491</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.011010</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>0.007954</td>\n",
       "      <td>0.023228</td>\n",
       "      <td>0.002077</td>\n",
       "      <td>0.085726</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>0.005785</td>\n",
       "      <td>0.015352</td>\n",
       "      <td>0.001167</td>\n",
       "      <td>0.056703</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>0.041908</td>\n",
       "      <td>0.132300</td>\n",
       "      <td>0.010473</td>\n",
       "      <td>0.470154</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>0.000023</td>\n",
       "      <td>0.000069</td>\n",
       "      <td>0.000004</td>\n",
       "      <td>0.000359</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>0.007618</td>\n",
       "      <td>0.024021</td>\n",
       "      <td>0.001655</td>\n",
       "      <td>0.085838</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>0.001984</td>\n",
       "      <td>0.005230</td>\n",
       "      <td>0.000361</td>\n",
       "      <td>0.011001</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>0.000207</td>\n",
       "      <td>0.000661</td>\n",
       "      <td>0.000081</td>\n",
       "      <td>0.002189</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>0.000404</td>\n",
       "      <td>0.001179</td>\n",
       "      <td>0.000107</td>\n",
       "      <td>0.004773</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>0.041531</td>\n",
       "      <td>0.131387</td>\n",
       "      <td>0.011746</td>\n",
       "      <td>0.492781</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>0.003195</td>\n",
       "      <td>0.010108</td>\n",
       "      <td>0.000891</td>\n",
       "      <td>0.033520</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>0.046395</td>\n",
       "      <td>0.145951</td>\n",
       "      <td>0.012325</td>\n",
       "      <td>0.534417</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>0.000878</td>\n",
       "      <td>0.002918</td>\n",
       "      <td>0.000232</td>\n",
       "      <td>0.009992</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>0.003132</td>\n",
       "      <td>0.009383</td>\n",
       "      <td>0.000777</td>\n",
       "      <td>0.034912</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>0.001569</td>\n",
       "      <td>0.005794</td>\n",
       "      <td>0.000618</td>\n",
       "      <td>0.016950</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>0.010054</td>\n",
       "      <td>0.024944</td>\n",
       "      <td>0.002243</td>\n",
       "      <td>0.092415</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>0.000279</td>\n",
       "      <td>0.000698</td>\n",
       "      <td>0.000040</td>\n",
       "      <td>0.002297</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>0.000533</td>\n",
       "      <td>0.001864</td>\n",
       "      <td>0.000222</td>\n",
       "      <td>0.008032</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>0.000763</td>\n",
       "      <td>0.002069</td>\n",
       "      <td>0.000145</td>\n",
       "      <td>0.007729</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>0.001212</td>\n",
       "      <td>0.005696</td>\n",
       "      <td>0.000727</td>\n",
       "      <td>0.018664</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34</th>\n",
       "      <td>0.001880</td>\n",
       "      <td>0.005912</td>\n",
       "      <td>0.000543</td>\n",
       "      <td>0.020392</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>0.043919</td>\n",
       "      <td>0.147046</td>\n",
       "      <td>0.011837</td>\n",
       "      <td>0.573127</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36</th>\n",
       "      <td>0.036691</td>\n",
       "      <td>0.105962</td>\n",
       "      <td>0.008228</td>\n",
       "      <td>0.637334</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>37</th>\n",
       "      <td>0.016365</td>\n",
       "      <td>0.054062</td>\n",
       "      <td>0.004300</td>\n",
       "      <td>0.250572</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38</th>\n",
       "      <td>0.001896</td>\n",
       "      <td>0.004915</td>\n",
       "      <td>0.000449</td>\n",
       "      <td>0.017513</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39</th>\n",
       "      <td>0.038694</td>\n",
       "      <td>0.126076</td>\n",
       "      <td>0.010886</td>\n",
       "      <td>0.417516</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40</th>\n",
       "      <td>0.023411</td>\n",
       "      <td>0.047679</td>\n",
       "      <td>0.004946</td>\n",
       "      <td>0.292997</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>41</th>\n",
       "      <td>0.049110</td>\n",
       "      <td>0.160447</td>\n",
       "      <td>0.013607</td>\n",
       "      <td>0.581491</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>42</th>\n",
       "      <td>0.011298</td>\n",
       "      <td>0.033546</td>\n",
       "      <td>0.002831</td>\n",
       "      <td>0.120189</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>43</th>\n",
       "      <td>0.003004</td>\n",
       "      <td>0.010957</td>\n",
       "      <td>0.001296</td>\n",
       "      <td>0.033930</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44</th>\n",
       "      <td>0.000266</td>\n",
       "      <td>0.000772</td>\n",
       "      <td>0.000040</td>\n",
       "      <td>0.002860</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>45</th>\n",
       "      <td>0.001499</td>\n",
       "      <td>0.006083</td>\n",
       "      <td>0.000264</td>\n",
       "      <td>0.018424</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46</th>\n",
       "      <td>0.000216</td>\n",
       "      <td>0.000903</td>\n",
       "      <td>0.000165</td>\n",
       "      <td>0.003332</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>47</th>\n",
       "      <td>0.002335</td>\n",
       "      <td>0.004871</td>\n",
       "      <td>0.000400</td>\n",
       "      <td>0.025355</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>48</th>\n",
       "      <td>0.025072</td>\n",
       "      <td>0.088302</td>\n",
       "      <td>0.006213</td>\n",
       "      <td>0.407433</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>49</th>\n",
       "      <td>0.012452</td>\n",
       "      <td>0.041834</td>\n",
       "      <td>0.002796</td>\n",
       "      <td>0.138645</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50</th>\n",
       "      <td>0.007464</td>\n",
       "      <td>0.020185</td>\n",
       "      <td>0.002082</td>\n",
       "      <td>0.071676</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>51</th>\n",
       "      <td>0.046176</td>\n",
       "      <td>0.129427</td>\n",
       "      <td>0.011051</td>\n",
       "      <td>0.464554</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>52</th>\n",
       "      <td>0.002163</td>\n",
       "      <td>0.007571</td>\n",
       "      <td>0.000295</td>\n",
       "      <td>0.023992</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>53</th>\n",
       "      <td>0.000674</td>\n",
       "      <td>0.002652</td>\n",
       "      <td>0.000090</td>\n",
       "      <td>0.007754</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>54</th>\n",
       "      <td>0.000055</td>\n",
       "      <td>0.000187</td>\n",
       "      <td>0.000022</td>\n",
       "      <td>0.000627</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>55</th>\n",
       "      <td>0.012188</td>\n",
       "      <td>0.025594</td>\n",
       "      <td>0.003656</td>\n",
       "      <td>0.131627</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>56</th>\n",
       "      <td>0.006995</td>\n",
       "      <td>0.024631</td>\n",
       "      <td>0.001512</td>\n",
       "      <td>0.087853</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>57</th>\n",
       "      <td>0.003987</td>\n",
       "      <td>0.015585</td>\n",
       "      <td>0.001450</td>\n",
       "      <td>0.051891</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>58</th>\n",
       "      <td>0.032834</td>\n",
       "      <td>0.106901</td>\n",
       "      <td>0.008781</td>\n",
       "      <td>0.377971</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>59</th>\n",
       "      <td>0.032937</td>\n",
       "      <td>0.114605</td>\n",
       "      <td>0.008429</td>\n",
       "      <td>0.399490</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>60</th>\n",
       "      <td>0.003281</td>\n",
       "      <td>0.009422</td>\n",
       "      <td>0.000757</td>\n",
       "      <td>0.032725</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>61</th>\n",
       "      <td>0.000096</td>\n",
       "      <td>0.000383</td>\n",
       "      <td>0.000096</td>\n",
       "      <td>0.000719</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>62</th>\n",
       "      <td>0.002549</td>\n",
       "      <td>0.005736</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.028681</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>63</th>\n",
       "      <td>0.000050</td>\n",
       "      <td>0.000404</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000858</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>64</th>\n",
       "      <td>0.043198</td>\n",
       "      <td>0.150166</td>\n",
       "      <td>0.013736</td>\n",
       "      <td>0.523490</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>65</th>\n",
       "      <td>0.036979</td>\n",
       "      <td>0.120903</td>\n",
       "      <td>0.010542</td>\n",
       "      <td>0.402652</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>66</th>\n",
       "      <td>0.002513</td>\n",
       "      <td>0.008480</td>\n",
       "      <td>0.000942</td>\n",
       "      <td>0.027219</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>67</th>\n",
       "      <td>0.001501</td>\n",
       "      <td>0.003001</td>\n",
       "      <td>0.000214</td>\n",
       "      <td>0.012647</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>68</th>\n",
       "      <td>0.001950</td>\n",
       "      <td>0.007701</td>\n",
       "      <td>0.000390</td>\n",
       "      <td>0.026808</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>69</th>\n",
       "      <td>0.002830</td>\n",
       "      <td>0.007475</td>\n",
       "      <td>0.000363</td>\n",
       "      <td>0.023222</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>70</th>\n",
       "      <td>0.000196</td>\n",
       "      <td>0.000982</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.002553</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>71</th>\n",
       "      <td>0.037465</td>\n",
       "      <td>0.083606</td>\n",
       "      <td>0.008423</td>\n",
       "      <td>0.428589</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>72</th>\n",
       "      <td>0.000174</td>\n",
       "      <td>0.000348</td>\n",
       "      <td>0.000099</td>\n",
       "      <td>0.002185</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>73</th>\n",
       "      <td>0.001316</td>\n",
       "      <td>0.007459</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.022378</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>74</th>\n",
       "      <td>0.002666</td>\n",
       "      <td>0.006634</td>\n",
       "      <td>0.000585</td>\n",
       "      <td>0.021852</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75</th>\n",
       "      <td>0.013636</td>\n",
       "      <td>0.020455</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.065909</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>76</th>\n",
       "      <td>0.027690</td>\n",
       "      <td>0.113915</td>\n",
       "      <td>0.008412</td>\n",
       "      <td>0.354364</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>77</th>\n",
       "      <td>0.000787</td>\n",
       "      <td>0.001416</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.005507</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>78</th>\n",
       "      <td>0.058537</td>\n",
       "      <td>0.166741</td>\n",
       "      <td>0.016851</td>\n",
       "      <td>0.596896</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>79</th>\n",
       "      <td>0.004792</td>\n",
       "      <td>0.027157</td>\n",
       "      <td>0.001597</td>\n",
       "      <td>0.081470</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>80</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>81</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000240</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>82</th>\n",
       "      <td>0.001522</td>\n",
       "      <td>0.007610</td>\n",
       "      <td>0.001522</td>\n",
       "      <td>0.060883</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>83</th>\n",
       "      <td>0.031719</td>\n",
       "      <td>0.105248</td>\n",
       "      <td>0.009516</td>\n",
       "      <td>0.365917</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>84</th>\n",
       "      <td>0.001548</td>\n",
       "      <td>0.003405</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.011142</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>85</th>\n",
       "      <td>0.007064</td>\n",
       "      <td>0.015655</td>\n",
       "      <td>0.001909</td>\n",
       "      <td>0.107484</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>0.030587</td>\n",
       "      <td>0.099251</td>\n",
       "      <td>0.009363</td>\n",
       "      <td>0.360799</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>87</th>\n",
       "      <td>0.038815</td>\n",
       "      <td>0.111546</td>\n",
       "      <td>0.010402</td>\n",
       "      <td>0.413987</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>88</th>\n",
       "      <td>0.022854</td>\n",
       "      <td>0.096689</td>\n",
       "      <td>0.007032</td>\n",
       "      <td>0.359801</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>89</th>\n",
       "      <td>0.007186</td>\n",
       "      <td>0.025509</td>\n",
       "      <td>0.001919</td>\n",
       "      <td>0.177320</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>90</th>\n",
       "      <td>0.001404</td>\n",
       "      <td>0.004493</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.010110</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>91</th>\n",
       "      <td>0.031847</td>\n",
       "      <td>0.093758</td>\n",
       "      <td>0.008408</td>\n",
       "      <td>0.307261</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>92</th>\n",
       "      <td>0.019316</td>\n",
       "      <td>0.077266</td>\n",
       "      <td>0.011887</td>\n",
       "      <td>0.322437</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>93</th>\n",
       "      <td>0.002215</td>\n",
       "      <td>0.008418</td>\n",
       "      <td>0.000443</td>\n",
       "      <td>0.022596</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>94</th>\n",
       "      <td>0.008639</td>\n",
       "      <td>0.021598</td>\n",
       "      <td>0.002160</td>\n",
       "      <td>0.144168</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>95</th>\n",
       "      <td>0.008923</td>\n",
       "      <td>0.034417</td>\n",
       "      <td>0.003824</td>\n",
       "      <td>0.168897</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>96</th>\n",
       "      <td>0.000776</td>\n",
       "      <td>0.001397</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.004812</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>97</th>\n",
       "      <td>0.048166</td>\n",
       "      <td>0.173508</td>\n",
       "      <td>0.012589</td>\n",
       "      <td>0.568144</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>98</th>\n",
       "      <td>0.048397</td>\n",
       "      <td>0.158017</td>\n",
       "      <td>0.015743</td>\n",
       "      <td>0.527114</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>99</th>\n",
       "      <td>0.001311</td>\n",
       "      <td>0.004261</td>\n",
       "      <td>0.000328</td>\n",
       "      <td>0.012783</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>100</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000371</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.001484</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>101</th>\n",
       "      <td>0.013999</td>\n",
       "      <td>0.029915</td>\n",
       "      <td>0.003389</td>\n",
       "      <td>0.137784</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>102</th>\n",
       "      <td>0.002387</td>\n",
       "      <td>0.009547</td>\n",
       "      <td>0.002387</td>\n",
       "      <td>0.019093</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>103</th>\n",
       "      <td>0.034483</td>\n",
       "      <td>0.073276</td>\n",
       "      <td>0.004310</td>\n",
       "      <td>0.334052</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>104</th>\n",
       "      <td>0.001411</td>\n",
       "      <td>0.004940</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.025406</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>105</th>\n",
       "      <td>0.030581</td>\n",
       "      <td>0.088685</td>\n",
       "      <td>0.018349</td>\n",
       "      <td>0.275229</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>106</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.003049</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.003049</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>107</th>\n",
       "      <td>0.002444</td>\n",
       "      <td>0.006354</td>\n",
       "      <td>0.000978</td>\n",
       "      <td>0.022972</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>108</th>\n",
       "      <td>0.002364</td>\n",
       "      <td>0.011820</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.040189</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>109</th>\n",
       "      <td>0.011662</td>\n",
       "      <td>0.049563</td>\n",
       "      <td>0.002915</td>\n",
       "      <td>0.104956</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>110</th>\n",
       "      <td>0.002225</td>\n",
       "      <td>0.010011</td>\n",
       "      <td>0.002225</td>\n",
       "      <td>0.061179</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>111</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.004386</td>\n",
       "      <td>0.000877</td>\n",
       "      <td>0.016667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>112</th>\n",
       "      <td>0.036932</td>\n",
       "      <td>0.116477</td>\n",
       "      <td>0.008523</td>\n",
       "      <td>0.375000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>113</th>\n",
       "      <td>0.006356</td>\n",
       "      <td>0.012712</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.074153</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>114</th>\n",
       "      <td>0.016129</td>\n",
       "      <td>0.080645</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.145161</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>115</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.083333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>116</th>\n",
       "      <td>0.008969</td>\n",
       "      <td>0.029148</td>\n",
       "      <td>0.004484</td>\n",
       "      <td>0.051570</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>117</th>\n",
       "      <td>0.010204</td>\n",
       "      <td>0.020408</td>\n",
       "      <td>0.003401</td>\n",
       "      <td>0.081633</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>118</th>\n",
       "      <td>0.034429</td>\n",
       "      <td>0.139280</td>\n",
       "      <td>0.009390</td>\n",
       "      <td>0.464789</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>119</th>\n",
       "      <td>0.000964</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.012536</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>120</th>\n",
       "      <td>0.003976</td>\n",
       "      <td>0.005964</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.061630</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>121</th>\n",
       "      <td>0.000907</td>\n",
       "      <td>0.007260</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.039020</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>122</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>123</th>\n",
       "      <td>0.054498</td>\n",
       "      <td>0.169402</td>\n",
       "      <td>0.013132</td>\n",
       "      <td>0.556139</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>124</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.026490</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>125</th>\n",
       "      <td>0.013142</td>\n",
       "      <td>0.024293</td>\n",
       "      <td>0.003186</td>\n",
       "      <td>0.147352</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>126</th>\n",
       "      <td>0.003958</td>\n",
       "      <td>0.005277</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.018470</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>127</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>128</th>\n",
       "      <td>0.005367</td>\n",
       "      <td>0.008945</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.076923</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>129</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.100000</td>\n",
       "      <td>0.050000</td>\n",
       "      <td>0.250000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>130</th>\n",
       "      <td>0.006070</td>\n",
       "      <td>0.006070</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.044006</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>131</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.001541</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.003082</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>132</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.047619</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.428571</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>133</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.100000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.520000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>134</th>\n",
       "      <td>0.014440</td>\n",
       "      <td>0.075812</td>\n",
       "      <td>0.014440</td>\n",
       "      <td>0.328520</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>135</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>136</th>\n",
       "      <td>0.015584</td>\n",
       "      <td>0.093506</td>\n",
       "      <td>0.005195</td>\n",
       "      <td>0.314286</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>137</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.020833</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>138</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.017241</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.155172</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>139</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>140</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.007576</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.030303</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>141</th>\n",
       "      <td>0.029412</td>\n",
       "      <td>0.058824</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.411765</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>142</th>\n",
       "      <td>0.046512</td>\n",
       "      <td>0.172093</td>\n",
       "      <td>0.037209</td>\n",
       "      <td>0.418605</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>143</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>144</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.007605</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.038023</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>145</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>147</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.250000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>148</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.037037</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>149</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.070588</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>150</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.250000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>151</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.250000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>152</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.384615</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>153</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>154</th>\n",
       "      <td>0.250000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>155</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>156</th>\n",
       "      <td>0.023810</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.023810</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>157</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.333333</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.333333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>158</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>159</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.200000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.600000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>160</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>161</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>162</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>163</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.200000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.600000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>164</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>165</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.080000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>166</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>167</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>0.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>168</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>170</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>171</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     reply   retweet retweet_comment      like\n",
       "                      mean      mean            mean      mean\n",
       "a_count_combined                                              \n",
       "0                 0.000134  0.000483        0.000036  0.001738\n",
       "1                 0.000122  0.000366        0.000028  0.001323\n",
       "2                 0.041770  0.186519        0.012111  0.736756\n",
       "3                 0.005150  0.016041        0.001395  0.058424\n",
       "4                 0.003689  0.014470        0.000967  0.051986\n",
       "5                 0.000054  0.000196        0.000017  0.000704\n",
       "6                 0.038237  0.128285        0.012932  0.545995\n",
       "7                 0.029493  0.110948        0.009350  0.476620\n",
       "8                 0.000804  0.002577        0.000232  0.015041\n",
       "9                 0.034245  0.113368        0.010275  0.491770\n",
       "10                0.028490  0.056141        0.005435  0.252894\n",
       "11                0.031611  0.112540        0.010479  0.413701\n",
       "12                0.000359  0.001182        0.000083  0.005582\n",
       "13                0.001775  0.005154        0.000360  0.018248\n",
       "14                0.000806  0.003491        0.000000  0.011010\n",
       "15                0.007954  0.023228        0.002077  0.085726\n",
       "16                0.005785  0.015352        0.001167  0.056703\n",
       "17                0.041908  0.132300        0.010473  0.470154\n",
       "18                0.000023  0.000069        0.000004  0.000359\n",
       "19                0.007618  0.024021        0.001655  0.085838\n",
       "20                0.001984  0.005230        0.000361  0.011001\n",
       "21                0.000207  0.000661        0.000081  0.002189\n",
       "22                0.000404  0.001179        0.000107  0.004773\n",
       "23                0.041531  0.131387        0.011746  0.492781\n",
       "24                0.003195  0.010108        0.000891  0.033520\n",
       "25                0.046395  0.145951        0.012325  0.534417\n",
       "26                0.000878  0.002918        0.000232  0.009992\n",
       "27                0.003132  0.009383        0.000777  0.034912\n",
       "28                0.001569  0.005794        0.000618  0.016950\n",
       "29                0.010054  0.024944        0.002243  0.092415\n",
       "30                0.000279  0.000698        0.000040  0.002297\n",
       "31                0.000533  0.001864        0.000222  0.008032\n",
       "32                0.000763  0.002069        0.000145  0.007729\n",
       "33                0.001212  0.005696        0.000727  0.018664\n",
       "34                0.001880  0.005912        0.000543  0.020392\n",
       "35                0.043919  0.147046        0.011837  0.573127\n",
       "36                0.036691  0.105962        0.008228  0.637334\n",
       "37                0.016365  0.054062        0.004300  0.250572\n",
       "38                0.001896  0.004915        0.000449  0.017513\n",
       "39                0.038694  0.126076        0.010886  0.417516\n",
       "40                0.023411  0.047679        0.004946  0.292997\n",
       "41                0.049110  0.160447        0.013607  0.581491\n",
       "42                0.011298  0.033546        0.002831  0.120189\n",
       "43                0.003004  0.010957        0.001296  0.033930\n",
       "44                0.000266  0.000772        0.000040  0.002860\n",
       "45                0.001499  0.006083        0.000264  0.018424\n",
       "46                0.000216  0.000903        0.000165  0.003332\n",
       "47                0.002335  0.004871        0.000400  0.025355\n",
       "48                0.025072  0.088302        0.006213  0.407433\n",
       "49                0.012452  0.041834        0.002796  0.138645\n",
       "50                0.007464  0.020185        0.002082  0.071676\n",
       "51                0.046176  0.129427        0.011051  0.464554\n",
       "52                0.002163  0.007571        0.000295  0.023992\n",
       "53                0.000674  0.002652        0.000090  0.007754\n",
       "54                0.000055  0.000187        0.000022  0.000627\n",
       "55                0.012188  0.025594        0.003656  0.131627\n",
       "56                0.006995  0.024631        0.001512  0.087853\n",
       "57                0.003987  0.015585        0.001450  0.051891\n",
       "58                0.032834  0.106901        0.008781  0.377971\n",
       "59                0.032937  0.114605        0.008429  0.399490\n",
       "60                0.003281  0.009422        0.000757  0.032725\n",
       "61                0.000096  0.000383        0.000096  0.000719\n",
       "62                0.002549  0.005736        0.000000  0.028681\n",
       "63                0.000050  0.000404        0.000000  0.000858\n",
       "64                0.043198  0.150166        0.013736  0.523490\n",
       "65                0.036979  0.120903        0.010542  0.402652\n",
       "66                0.002513  0.008480        0.000942  0.027219\n",
       "67                0.001501  0.003001        0.000214  0.012647\n",
       "68                0.001950  0.007701        0.000390  0.026808\n",
       "69                0.002830  0.007475        0.000363  0.023222\n",
       "70                0.000196  0.000982        0.000000  0.002553\n",
       "71                0.037465  0.083606        0.008423  0.428589\n",
       "72                0.000174  0.000348        0.000099  0.002185\n",
       "73                0.001316  0.007459        0.000000  0.022378\n",
       "74                0.002666  0.006634        0.000585  0.021852\n",
       "75                0.013636  0.020455        0.000000  0.065909\n",
       "76                0.027690  0.113915        0.008412  0.354364\n",
       "77                0.000787  0.001416        0.000000  0.005507\n",
       "78                0.058537  0.166741        0.016851  0.596896\n",
       "79                0.004792  0.027157        0.001597  0.081470\n",
       "80                0.000000  0.000000        0.000000  0.000000\n",
       "81                0.000000  0.000000        0.000000  0.000240\n",
       "82                0.001522  0.007610        0.001522  0.060883\n",
       "83                0.031719  0.105248        0.009516  0.365917\n",
       "84                0.001548  0.003405        0.000000  0.011142\n",
       "85                0.007064  0.015655        0.001909  0.107484\n",
       "86                0.030587  0.099251        0.009363  0.360799\n",
       "87                0.038815  0.111546        0.010402  0.413987\n",
       "88                0.022854  0.096689        0.007032  0.359801\n",
       "89                0.007186  0.025509        0.001919  0.177320\n",
       "90                0.001404  0.004493        0.000000  0.010110\n",
       "91                0.031847  0.093758        0.008408  0.307261\n",
       "92                0.019316  0.077266        0.011887  0.322437\n",
       "93                0.002215  0.008418        0.000443  0.022596\n",
       "94                0.008639  0.021598        0.002160  0.144168\n",
       "95                0.008923  0.034417        0.003824  0.168897\n",
       "96                0.000776  0.001397        0.000000  0.004812\n",
       "97                0.048166  0.173508        0.012589  0.568144\n",
       "98                0.048397  0.158017        0.015743  0.527114\n",
       "99                0.001311  0.004261        0.000328  0.012783\n",
       "100               0.000000  0.000371        0.000000  0.001484\n",
       "101               0.013999  0.029915        0.003389  0.137784\n",
       "102               0.002387  0.009547        0.002387  0.019093\n",
       "103               0.034483  0.073276        0.004310  0.334052\n",
       "104               0.001411  0.004940        0.000000  0.025406\n",
       "105               0.030581  0.088685        0.018349  0.275229\n",
       "106               0.000000  0.003049        0.000000  0.003049\n",
       "107               0.002444  0.006354        0.000978  0.022972\n",
       "108               0.002364  0.011820        0.000000  0.040189\n",
       "109               0.011662  0.049563        0.002915  0.104956\n",
       "110               0.002225  0.010011        0.002225  0.061179\n",
       "111               0.000000  0.004386        0.000877  0.016667\n",
       "112               0.036932  0.116477        0.008523  0.375000\n",
       "113               0.006356  0.012712        0.000000  0.074153\n",
       "114               0.016129  0.080645        0.000000  0.145161\n",
       "115               0.000000  0.000000        0.000000  0.083333\n",
       "116               0.008969  0.029148        0.004484  0.051570\n",
       "117               0.010204  0.020408        0.003401  0.081633\n",
       "118               0.034429  0.139280        0.009390  0.464789\n",
       "119               0.000964  0.000000        0.000000  0.012536\n",
       "120               0.003976  0.005964        0.000000  0.061630\n",
       "121               0.000907  0.007260        0.000000  0.039020\n",
       "122               0.000000  0.000000        0.000000  0.000000\n",
       "123               0.054498  0.169402        0.013132  0.556139\n",
       "124               0.000000  0.000000        0.000000  0.026490\n",
       "125               0.013142  0.024293        0.003186  0.147352\n",
       "126               0.003958  0.005277        0.000000  0.018470\n",
       "127               0.000000  0.000000        0.000000  0.000000\n",
       "128               0.005367  0.008945        0.000000  0.076923\n",
       "129               0.000000  0.100000        0.050000  0.250000\n",
       "130               0.006070  0.006070        0.000000  0.044006\n",
       "131               0.000000  0.001541        0.000000  0.003082\n",
       "132               0.000000  0.047619        0.000000  0.428571\n",
       "133               0.000000  0.100000        0.000000  0.520000\n",
       "134               0.014440  0.075812        0.014440  0.328520\n",
       "135               0.000000  0.000000        0.000000  0.000000\n",
       "136               0.015584  0.093506        0.005195  0.314286\n",
       "137               0.000000  0.000000        0.000000  0.020833\n",
       "138               0.000000  0.017241        0.000000  0.155172\n",
       "139               0.000000  0.000000        0.000000  0.000000\n",
       "140               0.000000  0.007576        0.000000  0.030303\n",
       "141               0.029412  0.058824        0.000000  0.411765\n",
       "142               0.046512  0.172093        0.037209  0.418605\n",
       "143               0.000000  0.000000        0.000000  0.000000\n",
       "144               0.000000  0.007605        0.000000  0.038023\n",
       "145               0.000000  0.000000        0.000000  0.000000\n",
       "146               0.000000  0.000000        0.000000  0.000000\n",
       "147               0.000000  0.000000        0.000000  0.250000\n",
       "148               0.000000  0.037037        0.000000  0.000000\n",
       "149               0.000000  0.000000        0.000000  0.070588\n",
       "150               0.000000  0.000000        0.000000  0.250000\n",
       "151               0.000000  0.000000        0.000000  0.250000\n",
       "152               0.000000  0.000000        0.000000  0.384615\n",
       "153               0.000000  0.000000        0.000000  0.000000\n",
       "154               0.250000  0.000000        0.000000  0.000000\n",
       "155               0.000000  0.000000        0.000000  0.000000\n",
       "156               0.023810  0.000000        0.000000  0.023810\n",
       "157               0.000000  0.333333        0.000000  0.333333\n",
       "158               0.000000  0.000000        0.000000  0.000000\n",
       "159               0.000000  0.200000        0.000000  0.600000\n",
       "160               0.000000  0.000000        0.000000  0.000000\n",
       "161               0.000000  0.000000        0.000000  0.000000\n",
       "162               0.000000  0.000000        0.000000  0.000000\n",
       "163               0.000000  0.200000        0.000000  0.600000\n",
       "164               0.000000  0.000000        0.000000  0.500000\n",
       "165               0.000000  0.000000        0.000000  0.080000\n",
       "166               0.000000  0.000000        0.000000  0.500000\n",
       "167               0.000000  0.500000        0.500000  0.500000\n",
       "168               0.000000  0.000000        0.000000  1.000000\n",
       "169               0.000000  0.500000        0.000000  0.500000\n",
       "170               0.000000  0.000000        0.000000  1.000000\n",
       "171               0.000000  0.000000        0.000000  0.000000"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train.loc[ train.tr==0 ].groupby('a_count_combined')[['reply','retweet','retweet_comment','like']].agg(['mean'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>hashtags</th>\n",
       "      <th>tweet_id</th>\n",
       "      <th>media</th>\n",
       "      <th>links</th>\n",
       "      <th>domains</th>\n",
       "      <th>tweet_type</th>\n",
       "      <th>language</th>\n",
       "      <th>timestamp</th>\n",
       "      <th>a_user_id</th>\n",
       "      <th>a_follower_count</th>\n",
       "      <th>a_following_count</th>\n",
       "      <th>a_is_verified</th>\n",
       "      <th>a_account_creation</th>\n",
       "      <th>b_user_id</th>\n",
       "      <th>b_follower_count</th>\n",
       "      <th>b_following_count</th>\n",
       "      <th>b_is_verified</th>\n",
       "      <th>b_account_creation</th>\n",
       "      <th>b_follows_a</th>\n",
       "      <th>reply</th>\n",
       "      <th>retweet</th>\n",
       "      <th>retweet_comment</th>\n",
       "      <th>like</th>\n",
       "      <th>id</th>\n",
       "      <th>tr</th>\n",
       "      <th>engage</th>\n",
       "      <th>a_user_fer_count_delta_time</th>\n",
       "      <th>a_user_fing_count_delta_time</th>\n",
       "      <th>a_user_fering_count_delta_time</th>\n",
       "      <th>a_user_fing_count_mode</th>\n",
       "      <th>a_user_fer_count_mode</th>\n",
       "      <th>a_user_fering_count_mode</th>\n",
       "      <th>a_count_combined</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>84383</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>59</td>\n",
       "      <td>1580947200</td>\n",
       "      <td>7581</td>\n",
       "      <td>1438254</td>\n",
       "      <td>268</td>\n",
       "      <td>1</td>\n",
       "      <td>1301520627</td>\n",
       "      <td>22274968</td>\n",
       "      <td>41</td>\n",
       "      <td>379</td>\n",
       "      <td>0</td>\n",
       "      <td>1259102347</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>96855085</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0</td>\n",
       "      <td>3992746</td>\n",
       "      <td>5</td>\n",
       "      <td>473701</td>\n",
       "      <td>9</td>\n",
       "      <td>2</td>\n",
       "      <td>59</td>\n",
       "      <td>1580947200</td>\n",
       "      <td>4749</td>\n",
       "      <td>1045996</td>\n",
       "      <td>518</td>\n",
       "      <td>1</td>\n",
       "      <td>1235504861</td>\n",
       "      <td>23956872</td>\n",
       "      <td>0</td>\n",
       "      <td>64</td>\n",
       "      <td>0</td>\n",
       "      <td>1557970591</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>57701281</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0</td>\n",
       "      <td>789758</td>\n",
       "      <td>9</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>54</td>\n",
       "      <td>1580947200</td>\n",
       "      <td>12117</td>\n",
       "      <td>71231</td>\n",
       "      <td>3819</td>\n",
       "      <td>0</td>\n",
       "      <td>1352943191</td>\n",
       "      <td>18642489</td>\n",
       "      <td>13</td>\n",
       "      <td>65</td>\n",
       "      <td>0</td>\n",
       "      <td>1524243737</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>89623685</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0</td>\n",
       "      <td>6912703</td>\n",
       "      <td>5</td>\n",
       "      <td>141941</td>\n",
       "      <td>9</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>1580947200</td>\n",
       "      <td>297779</td>\n",
       "      <td>209838</td>\n",
       "      <td>204</td>\n",
       "      <td>1</td>\n",
       "      <td>1333746722</td>\n",
       "      <td>19850999</td>\n",
       "      <td>75</td>\n",
       "      <td>968</td>\n",
       "      <td>0</td>\n",
       "      <td>1306118149</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>51022269</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0</td>\n",
       "      <td>1508672</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>54</td>\n",
       "      <td>1580947200</td>\n",
       "      <td>53927</td>\n",
       "      <td>161464</td>\n",
       "      <td>5531</td>\n",
       "      <td>1</td>\n",
       "      <td>1260797124</td>\n",
       "      <td>15177916</td>\n",
       "      <td>94</td>\n",
       "      <td>220</td>\n",
       "      <td>0</td>\n",
       "      <td>1321907890</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2699787</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   hashtags  tweet_id  media   links  domains  tweet_type  language  \\\n",
       "0         0     84383      5       0        0           2        59   \n",
       "1         0   3992746      5  473701        9           2        59   \n",
       "2         0    789758      9       0        0           2        54   \n",
       "3         0   6912703      5  141941        9           2         3   \n",
       "4         0   1508672      5       0        0           2        54   \n",
       "\n",
       "    timestamp  a_user_id  a_follower_count  a_following_count  a_is_verified  \\\n",
       "0  1580947200       7581           1438254                268              1   \n",
       "1  1580947200       4749           1045996                518              1   \n",
       "2  1580947200      12117             71231               3819              0   \n",
       "3  1580947200     297779            209838                204              1   \n",
       "4  1580947200      53927            161464               5531              1   \n",
       "\n",
       "   a_account_creation  b_user_id  b_follower_count  b_following_count  \\\n",
       "0          1301520627   22274968                41                379   \n",
       "1          1235504861   23956872                 0                 64   \n",
       "2          1352943191   18642489                13                 65   \n",
       "3          1333746722   19850999                75                968   \n",
       "4          1260797124   15177916                94                220   \n",
       "\n",
       "   b_is_verified  b_account_creation  b_follows_a  reply  retweet  \\\n",
       "0              0          1259102347            0      0        0   \n",
       "1              0          1557970591            0      0        0   \n",
       "2              0          1524243737            0      0        0   \n",
       "3              0          1306118149            0      0        0   \n",
       "4              0          1321907890            0      0        0   \n",
       "\n",
       "   retweet_comment  like        id  tr  engage  a_user_fer_count_delta_time  \\\n",
       "0                0     0  96855085   0       0                            0   \n",
       "1                0     0  57701281   0       0                            0   \n",
       "2                0     0  89623685   0       0                            0   \n",
       "3                0     0  51022269   0       0                            0   \n",
       "4                0     1   2699787   0       1                            1   \n",
       "\n",
       "   a_user_fing_count_delta_time  a_user_fering_count_delta_time  \\\n",
       "0                             1                               0   \n",
       "1                             1                               0   \n",
       "2                             0                               0   \n",
       "3                             1                               0   \n",
       "4                             1                               1   \n",
       "\n",
       "   a_user_fing_count_mode  a_user_fer_count_mode  a_user_fering_count_mode  \\\n",
       "0                       1                      0                         0   \n",
       "1                       1                      0                         0   \n",
       "2                       0                      0                         0   \n",
       "3                       1                      0                         0   \n",
       "4                       1                      1                         1   \n",
       "\n",
       "   a_count_combined  \n",
       "0                 0  \n",
       "1                 0  \n",
       "2                 1  \n",
       "3                 0  \n",
       "4                 2  "
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>a_count_combined</th>\n",
       "      <th>a_user_fer_count_delta_time</th>\n",
       "      <th>a_user_fing_count_delta_time</th>\n",
       "      <th>a_user_fering_count_delta_time</th>\n",
       "      <th>a_user_fing_count_mode</th>\n",
       "      <th>a_user_fer_count_mode</th>\n",
       "      <th>a_user_fering_count_mode</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>146255954</th>\n",
       "      <td>146255954</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146255955</th>\n",
       "      <td>146255955</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146255956</th>\n",
       "      <td>146255956</td>\n",
       "      <td>10</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146255957</th>\n",
       "      <td>146255957</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146255958</th>\n",
       "      <td>146255958</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146255959</th>\n",
       "      <td>146255959</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146255960</th>\n",
       "      <td>146255960</td>\n",
       "      <td>25</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146255961</th>\n",
       "      <td>146255961</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146255962</th>\n",
       "      <td>146255962</td>\n",
       "      <td>10</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146255963</th>\n",
       "      <td>146255963</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146255964</th>\n",
       "      <td>146255964</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146255965</th>\n",
       "      <td>146255965</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146255966</th>\n",
       "      <td>146255966</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146255967</th>\n",
       "      <td>146255967</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146255968</th>\n",
       "      <td>146255968</td>\n",
       "      <td>10</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146255969</th>\n",
       "      <td>146255969</td>\n",
       "      <td>10</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146255970</th>\n",
       "      <td>146255970</td>\n",
       "      <td>29</td>\n",
       "      <td>1</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "      <td>1</td>\n",
       "      <td>-1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146255971</th>\n",
       "      <td>146255971</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146255972</th>\n",
       "      <td>146255972</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146255973</th>\n",
       "      <td>146255973</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146255974</th>\n",
       "      <td>146255974</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146255975</th>\n",
       "      <td>146255975</td>\n",
       "      <td>25</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146255976</th>\n",
       "      <td>146255976</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146255977</th>\n",
       "      <td>146255977</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146255978</th>\n",
       "      <td>146255978</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146255979</th>\n",
       "      <td>146255979</td>\n",
       "      <td>10</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146255980</th>\n",
       "      <td>146255980</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146255981</th>\n",
       "      <td>146255981</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146255982</th>\n",
       "      <td>146255982</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146255983</th>\n",
       "      <td>146255983</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146255984</th>\n",
       "      <td>146255984</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146255985</th>\n",
       "      <td>146255985</td>\n",
       "      <td>10</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146255986</th>\n",
       "      <td>146255986</td>\n",
       "      <td>35</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146255987</th>\n",
       "      <td>146255987</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146255988</th>\n",
       "      <td>146255988</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146255989</th>\n",
       "      <td>146255989</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146255990</th>\n",
       "      <td>146255990</td>\n",
       "      <td>10</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146255991</th>\n",
       "      <td>146255991</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146255992</th>\n",
       "      <td>146255992</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146255993</th>\n",
       "      <td>146255993</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146255994</th>\n",
       "      <td>146255994</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146255995</th>\n",
       "      <td>146255995</td>\n",
       "      <td>10</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146255996</th>\n",
       "      <td>146255996</td>\n",
       "      <td>15</td>\n",
       "      <td>-1</td>\n",
       "      <td>1</td>\n",
       "      <td>-1</td>\n",
       "      <td>1</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146255997</th>\n",
       "      <td>146255997</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146255998</th>\n",
       "      <td>146255998</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146255999</th>\n",
       "      <td>146255999</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146256000</th>\n",
       "      <td>146256000</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146256001</th>\n",
       "      <td>146256001</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146256002</th>\n",
       "      <td>146256002</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146256003</th>\n",
       "      <td>146256003</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                  id  a_count_combined  a_user_fer_count_delta_time  \\\n",
       "146255954  146255954                 2                            1   \n",
       "146255955  146255955                 2                            1   \n",
       "146255956  146255956                10                           -1   \n",
       "146255957  146255957                 0                            0   \n",
       "146255958  146255958                 0                            0   \n",
       "146255959  146255959                 2                            1   \n",
       "146255960  146255960                25                            0   \n",
       "146255961  146255961                 2                            1   \n",
       "146255962  146255962                10                           -1   \n",
       "146255963  146255963                 0                            0   \n",
       "146255964  146255964                 0                            0   \n",
       "146255965  146255965                 2                            1   \n",
       "146255966  146255966                 0                            0   \n",
       "146255967  146255967                 2                            1   \n",
       "146255968  146255968                10                           -1   \n",
       "146255969  146255969                10                           -1   \n",
       "146255970  146255970                29                            1   \n",
       "146255971  146255971                 2                            1   \n",
       "146255972  146255972                 2                            1   \n",
       "146255973  146255973                 2                            1   \n",
       "146255974  146255974                 2                            1   \n",
       "146255975  146255975                25                            0   \n",
       "146255976  146255976                 2                            1   \n",
       "146255977  146255977                 2                            1   \n",
       "146255978  146255978                 2                            1   \n",
       "146255979  146255979                10                           -1   \n",
       "146255980  146255980                 2                            1   \n",
       "146255981  146255981                 1                            0   \n",
       "146255982  146255982                 2                            1   \n",
       "146255983  146255983                 0                            0   \n",
       "146255984  146255984                 2                            1   \n",
       "146255985  146255985                10                           -1   \n",
       "146255986  146255986                35                            1   \n",
       "146255987  146255987                 0                            0   \n",
       "146255988  146255988                 2                            1   \n",
       "146255989  146255989                 2                            1   \n",
       "146255990  146255990                10                           -1   \n",
       "146255991  146255991                 0                            0   \n",
       "146255992  146255992                 2                            1   \n",
       "146255993  146255993                 2                            1   \n",
       "146255994  146255994                 0                            0   \n",
       "146255995  146255995                10                           -1   \n",
       "146255996  146255996                15                           -1   \n",
       "146255997  146255997                 2                            1   \n",
       "146255998  146255998                 2                            1   \n",
       "146255999  146255999                 2                            1   \n",
       "146256000  146256000                 0                            0   \n",
       "146256001  146256001                 2                            1   \n",
       "146256002  146256002                 2                            1   \n",
       "146256003  146256003                 2                            1   \n",
       "\n",
       "           a_user_fing_count_delta_time  a_user_fering_count_delta_time  \\\n",
       "146255954                             1                               1   \n",
       "146255955                             1                               1   \n",
       "146255956                            -1                              -1   \n",
       "146255957                             1                               0   \n",
       "146255958                             1                               0   \n",
       "146255959                             1                               1   \n",
       "146255960                             1                               1   \n",
       "146255961                             1                               1   \n",
       "146255962                            -1                              -1   \n",
       "146255963                             1                               0   \n",
       "146255964                             1                               0   \n",
       "146255965                             1                               1   \n",
       "146255966                             1                               0   \n",
       "146255967                             1                               1   \n",
       "146255968                            -1                              -1   \n",
       "146255969                            -1                              -1   \n",
       "146255970                            -1                              -1   \n",
       "146255971                             1                               1   \n",
       "146255972                             1                               1   \n",
       "146255973                             1                               1   \n",
       "146255974                             1                               1   \n",
       "146255975                             1                               1   \n",
       "146255976                             1                               1   \n",
       "146255977                             1                               1   \n",
       "146255978                             1                               1   \n",
       "146255979                            -1                              -1   \n",
       "146255980                             1                               1   \n",
       "146255981                             0                               0   \n",
       "146255982                             1                               1   \n",
       "146255983                             1                               0   \n",
       "146255984                             1                               1   \n",
       "146255985                            -1                              -1   \n",
       "146255986                             0                               1   \n",
       "146255987                             1                               0   \n",
       "146255988                             1                               1   \n",
       "146255989                             1                               1   \n",
       "146255990                            -1                              -1   \n",
       "146255991                             1                               0   \n",
       "146255992                             1                               1   \n",
       "146255993                             1                               1   \n",
       "146255994                             1                               0   \n",
       "146255995                            -1                              -1   \n",
       "146255996                             1                              -1   \n",
       "146255997                             1                               1   \n",
       "146255998                             1                               1   \n",
       "146255999                             1                               1   \n",
       "146256000                             1                               0   \n",
       "146256001                             1                               1   \n",
       "146256002                             1                               1   \n",
       "146256003                             1                               1   \n",
       "\n",
       "           a_user_fing_count_mode  a_user_fer_count_mode  \\\n",
       "146255954                       1                      1   \n",
       "146255955                       1                      1   \n",
       "146255956                      -1                     -1   \n",
       "146255957                       1                      0   \n",
       "146255958                       1                      0   \n",
       "146255959                       1                      1   \n",
       "146255960                       1                      1   \n",
       "146255961                       1                      1   \n",
       "146255962                      -1                     -1   \n",
       "146255963                       1                      0   \n",
       "146255964                       1                      0   \n",
       "146255965                       1                      1   \n",
       "146255966                       1                      0   \n",
       "146255967                       1                      1   \n",
       "146255968                      -1                     -1   \n",
       "146255969                      -1                     -1   \n",
       "146255970                      -1                      1   \n",
       "146255971                       1                      1   \n",
       "146255972                       1                      1   \n",
       "146255973                       1                      1   \n",
       "146255974                       1                      1   \n",
       "146255975                       1                      1   \n",
       "146255976                       1                      1   \n",
       "146255977                       1                      1   \n",
       "146255978                       1                      1   \n",
       "146255979                      -1                     -1   \n",
       "146255980                       1                      1   \n",
       "146255981                       0                      0   \n",
       "146255982                       1                      1   \n",
       "146255983                       1                      0   \n",
       "146255984                       1                      1   \n",
       "146255985                      -1                     -1   \n",
       "146255986                       1                      1   \n",
       "146255987                       1                      0   \n",
       "146255988                       1                      1   \n",
       "146255989                       1                      1   \n",
       "146255990                      -1                     -1   \n",
       "146255991                       1                      0   \n",
       "146255992                       1                      1   \n",
       "146255993                       1                      1   \n",
       "146255994                       1                      0   \n",
       "146255995                      -1                     -1   \n",
       "146255996                       1                     -1   \n",
       "146255997                       1                      1   \n",
       "146255998                       1                      1   \n",
       "146255999                       1                      1   \n",
       "146256000                       1                      0   \n",
       "146256001                       1                      1   \n",
       "146256002                       1                      1   \n",
       "146256003                       1                      1   \n",
       "\n",
       "           a_user_fering_count_mode  \n",
       "146255954                         1  \n",
       "146255955                         1  \n",
       "146255956                        -1  \n",
       "146255957                         0  \n",
       "146255958                         0  \n",
       "146255959                         1  \n",
       "146255960                         1  \n",
       "146255961                         1  \n",
       "146255962                        -1  \n",
       "146255963                         0  \n",
       "146255964                         0  \n",
       "146255965                         1  \n",
       "146255966                         0  \n",
       "146255967                         1  \n",
       "146255968                        -1  \n",
       "146255969                        -1  \n",
       "146255970                        -1  \n",
       "146255971                         1  \n",
       "146255972                         1  \n",
       "146255973                         1  \n",
       "146255974                         1  \n",
       "146255975                         1  \n",
       "146255976                         1  \n",
       "146255977                         1  \n",
       "146255978                         1  \n",
       "146255979                        -1  \n",
       "146255980                         1  \n",
       "146255981                         0  \n",
       "146255982                         1  \n",
       "146255983                         0  \n",
       "146255984                         1  \n",
       "146255985                        -1  \n",
       "146255986                         1  \n",
       "146255987                         0  \n",
       "146255988                         1  \n",
       "146255989                         1  \n",
       "146255990                        -1  \n",
       "146255991                         0  \n",
       "146255992                         1  \n",
       "146255993                         1  \n",
       "146255994                         0  \n",
       "146255995                        -1  \n",
       "146255996                        -1  \n",
       "146255997                         1  \n",
       "146255998                         1  \n",
       "146255999                         1  \n",
       "146256000                         0  \n",
       "146256001                         1  \n",
       "146256002                         1  \n",
       "146256003                         1  "
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dt = train[['id','a_count_combined','a_user_fer_count_delta_time','a_user_fing_count_delta_time','a_user_fering_count_delta_time','a_user_fing_count_mode','a_user_fer_count_mode','a_user_fering_count_mode']]\n",
    "dt = dt.sort_values( 'id' )\n",
    "dt = dt.reset_index( drop=True )\n",
    "save_memory( dt )\n",
    "dt.to_parquet( 'a_count_combined-final.parquet' )\n",
    "dt.tail(50)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
